// pages/qiye_jieshao/qiye_jieshao.js
const app = getApp()
//获得全局js变量
var util = require('../../utils/util.js');
Page({
  data: {
    list: [],
    type: 1,
    id: 0,
    userinfo: [],
    year: '',
    month: '',
    isShow: true
  },

  onLoad(options) {
    this.setData({
      userinfo: wx.getStorageSync('user'),
      id: options.id,
      type: options.type
    });

    const date = new Date();
    this.setData({
      year: date.getFullYear(),
      month: date.getMonth() + 1
    });

    wx.setNavigationBarTitle({
      title: '收益列表'
    });

    this.getinfo();
  },
   bindDateChange: function(e) {
    var date = e.detail.value;
    var arr = date.split('-');
    this.setData({
      year: arr[0],
      month:arr[1]
    })

    this.getinfo();
  },
  onCancel() {
    this.setData({
      isShow: !this.data.isShow
    });
  },

  getinfo() {
    const that = this;
    util.httpRrquest(app.data.apiurl + 'shop/getCommDetail', 'GET', {year: that.data.year,
        month: that.data.month,
        type: that.data.type})
    .then(function (response) {
        var list=response.data.data;
        that.setData({
            list:list
        });
    }, function (error) {
        console.log(error);
    });

    wx.request({
      url: 'https://your-api-url.com/shop/getCommDetail',
      data: {
        year: that.data.year,
        month: that.data.month,
        type: that.data.type
      },
      success(res) {
        that.setData({
          list: res.data
        });
      },
      fail(err) {
        console.log(err);
      }
    });
  }
});